﻿<!DOCTYPE html>
<html lang="en">
<head>
    <title id="Description">This sample demonstrates how we can localize the jqxTreeGrid</title>
    <meta name="description" content="Tree Grid Localization - JavaScript Tree Grid Demo | jQWidgets">
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcalendar.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdatetimeinput.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdatatable.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxtreegrid.js"></script>
    <script type="text/javascript" src="../../scripts/demos.js"></script>
    <script type="text/javascript" src="../../jqwidgets/globalization/globalize.js"></script>
    <script type="text/javascript" src="../sampledata/generatedata.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var getLocalization = function () {
                var localizationobj = {};
                localizationobj.pagerGoToPageString = "Gehe zu:";
                localizationobj.pagerShowRowsString = "Zeige Zeile:";
                localizationobj.pagerRangeString = " von ";
                localizationobj.pagerNextButtonString = "voriger";
                localizationobj.pagerFirstButtonString = "erste";
                localizationobj.pagerLastButtonString = "letzte";
                localizationobj.pagerPreviousButtonString = "nächster";
                localizationobj.sortAscendingString = "Sortiere aufsteigend";
                localizationobj.sortDescendingString = "Sortiere absteigend";
                localizationobj.sortRemoveString = "Entferne Sortierung";
                localizationobj.emptydatastring = "keine Daten angezeigt";
                localizationobj.firstDay = 1;
                localizationobj.percentSymbol = "%";
                localizationobj.currencySymbol = "€";
                localizationobj.currencySymbolPosition = "after";
                localizationobj.decimalSeparator = ".";
                localizationobj.thousandsSeparator = ",";
                var days = {
                    // full day names
                    names: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"],
                    // abbreviated day names
                    namesAbbr: ["Sonn", "Mon", "Dien", "Mitt", "Donn", "Fre", "Sams"],
                    // shortest day names
                    namesShort: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"]
                };
                localizationobj.days = days;
                var months = {
                    // full month names (13 months for lunar calendards -- 13th month should be "" if not lunar)
                    names: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember", ""],
                    // abbreviated month names
                    namesAbbr: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dez", ""]
                };
                var patterns = {
                    d: "dd.MM.yyyy",
                    D: "dddd, d. MMMM yyyy",
                    t: "HH:mm",
                    T: "HH:mm:ss",
                    f: "dddd, d. MMMM yyyy HH:mm",
                    F: "dddd, d. MMMM yyyy HH:mm:ss",
                    M: "dd MMMM",
                    Y: "MMMM yyyy"
                }
                localizationobj.patterns = patterns;
                localizationobj.months = months;
                return localizationobj;
            }

            // prepare the data
            var source =
            {
                dataType: "array",
                dataFields: [
                    { name: "name", type: "string" },
                    { name: "quantity", type: "number" },
                    { name: "id", type: "number" },
                    { name: "parentid", type: "number" },
                    { name: "price", type: "number" },
                    { name: "date", type: "date" },
                    { name: "customer", type: "string" }
                ],
                hierarchy:
                {
                    keyDataField: { name: 'id' },
                    parentDataField: { name: 'parentid' }
                },
                id: 'id',
                localData: generateordersdata()
            };
            var dataAdapter = new $.jqx.dataAdapter(source);
            // create Tree Grid
            $("#treeGrid").jqxTreeGrid(
            {
                width: 850,
                source: dataAdapter,
                sortable: true,
                pageable: true,
                pagerMode: 'advanced',
                localization: getLocalization(),
                ready: function () {
                    $("#treeGrid").jqxTreeGrid('expandRow', '2');
                },
                columns: [
                  { text: 'Bestellung Name', dataField: "name", align: 'center', width: 250 },
                  { text: 'Auftraggeber', dataField: "customer", align: 'center', width: 250 },
                  { text: 'Preis', dataField: "price", cellsFormat: "c2", align: 'center', cellsAlign: 'right', width: 180 },
                  {
                      text: 'Bestellung Datum', dataField: "date", align: 'center', cellsFormat: "dd-MMMM-yyyy hh:mm",
                      cellsRenderer: function (rowKey, column, cellValue, rowData, cellText) {
                          if (rowData.level === 0) {
                              return dataAdapter.formatDate(cellValue, "dd-MMMM-yyyy");
                          }
                          return cellText;
                      }
                  }
                ]
            });
        });
    </script>
</head>
<body class='default'>
    <div id="treeGrid">
    </div>
</body>
</html>
